describe("E2E: Test Suite for AMail", function() {
  beforeEach(function() {
    browser().navigateTo("http://localhost:9876/base/dist/views/index.html#/");
    expect(browser().window().href()).toBe("http://localhost:9876/base/dist/views/index.html#/");
    sleep(1);
  });

  it("E2E: Test for removeAll function", function() {
    // remove all item;
    element(".btn-toolbar .btn:nth(2)").click();

    expect(repeater("tbody tr").count()).toBe(0);
  });

  it("E2E: Test for new Message function", function() {
    var newMessageBtn = element(".btn-toolbar .btn:first", "New Message");
    newMessageBtn.click();

    sleep(1);
    var str = browser().window().href();

    expect(str).toContain("/new/");

    sleep(1);

    input("subject").enter("Test New Message" + new Date().getTime());
    input("to").enter("wusende@gmail.com");
    input("cc").enter("wusende@gmail.com");
    input("message").enter("Test New Message send Message");

    element(".btn:first").click();

    sleep(1);
    expect(element("#save-result:visible").count()).toBe(1);

    element(".btn:nth(1)").click();

    browser().navigateTo("http://localhost:9876/base/dist/views/index.html#/");
    sleep(5);

    expect(repeater("tbody tr").count()).toBeGreaterThan(0);

  });

  it("E2E: Test for remove function", function() {
    element("tbody tr:last").click();

    // remove all item;
    element(".btn-toolbar .btn:nth(1)").click();

    sleep(1);
    expect(repeater("tbody tr").count()).toBe(0);
  });
});